package cn.zlj.nmcc.service.impl;

import cn.zlj.nmcc.domain.Login;
import cn.zlj.nmcc.exception.GlobalExceptionCodeEnum;
import cn.zlj.nmcc.mapper.LoginMapper;
import cn.zlj.nmcc.result.JSONResult;
import cn.zlj.nmcc.service.ILoginService;
import cn.zlj.nmcc.util.AssertUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 登录表 服务实现类
 * </p>
 *
 * @author zlj
 * @since 2022-11-17
 */
@Service
public class LoginServiceImpl extends ServiceImpl<LoginMapper, Login> implements ILoginService {

    @Override
    public JSONResult loginCommon(Login login) {

        Wrapper<Login> wrapper=new EntityWrapper<>();
        wrapper.eq("username",login.getUsername());
        wrapper.eq("password",login.getPassword());
        wrapper.eq("type",login.getType());
        Login one =selectOne(wrapper);
        AssertUtil.isNotNull(one, GlobalExceptionCodeEnum.UAA_NOT_IS_EXISTS);


        return JSONResult.success(one);
    }
}
